<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理</title>

    <script src="__STATIC__/jquery-2.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    {include file="public/header" /}
    {include file="public/left" /}
    <style>
        .layui-table-cell{
            height: 33px;
        }
    </style>



    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">


            <fieldset class="layui-elem-field layui-field-title"  style="margin-top: 50px;">
                <legend>血糖历史记录</legend>
            </fieldset>

            <form class="layui-form" action="">
                <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">起始日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="sdate" id="sdate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束日期</label>
                <div class="layui-input-inline">
                    <input type="text" name="edate" id="edate" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            <button class="layui-btn" id="searchbtn" data-type="reload">搜索</button>

                </div>

            </form>

            <table class="layui-hide" id="list"></table>



            <script>
                layui.use('table', function(){
                    var table = layui.table;

                    table.render({
                        elem: '#list'

                        ,url: "{:url('Treat/bshistoryjson')}?uid="+{$uid}
                        ,cols: [[
                            {type:'checkbox',width:'4%'}
                            ,{field:'date', width:'4%', title: '时间', sort: true}
                            ,{field:'insulinDate', width:'8%', title: '胰岛素总量(u)', sort: true}
                            ,{field:'baseandbeforeeatin', width:'10%', title: '基础总/餐前总(u)', sort: true}
                            ,{field:'yejian3dian', width:'10%', title: '夜间3点(血糖/剂量)'}
                            ,{field:'zaocanqian', width:'10%', title: '早餐前(血糖/剂量)'}
                            ,{field:'zaocanhou', width: '9%', title: '早餐后(血糖/剂量)' }
                            ,{field:'wucanqian', width: '9%', title: '午餐前(血糖/剂量)' }
                            ,{field:'wucanhou', width: '9%', title: '午餐后(血糖/剂量)' }
                            ,{field:'wancanqian', width: '9%', title: '晚餐前(血糖/剂量)' }
                            ,{field:'wancanhou', width: '9%', title: '晚餐后(血糖/剂量)' }
                            ,{field:'shuiqian', width: '9%', title: '睡前(血糖/剂量)' }
//
                        ]]
                        ,page: true
                        ,id:'tb'
                    });

                    var $ = layui.$, active = {
                        reload: function(){
                            var sdate = $('#sdate');
                            var edate = $('#edate');


                            //执行重载
                            table.reload('tb', {
                                page: {
                                    curr: 1 //重新从第 1 页开始
                                }
                                ,where: {
                                    key: {
                                        sdate: sdate.val(),
                                        edate: edate.val(),
                                    }
                                }
                            });
                        }
                    };

                    $('#searchbtn').on('click', function(e){
                        e.preventDefault();

                        var type = $(this).data('type');

                        active[type] ? active[type].call(this) : '';
//                        alert();
                    });
                });
            </script>


        </div>
    </div>


</div>

<script>

    //JavaScript代码区域
    layui.use('laydate', function(){

        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#sdate'

        });
        laydate.render({
            elem: '#edate'

        });

    });
    $('#logout').click(function (e) {
        e.preventDefault();
        layui.use('layer', function(){
            var layer = layui.layer;

            layer.confirm('你真的要退出吗？',['yes','no'],function () {
                location.href="{:url('login/logout')}";
            },function () {
                
            })
        });
    })





</script>

</body>
</html>